import java.io.Serializable;
import java.util.AbstractCollection;
import java.util.ArrayList;


//This is just an idea I'm having, but we can use this to find any prescriptions or labwork.
//More than anything, we can probably use this as a little extra credit.  If the database doesn't
//go up, we'll simply have possible procedures (Labwork/prescriptions) hard-coded.
public abstract class ProcedureDatabase implements Serializable {

	static AbstractCollection<Prescription> PrescriptionList =
		new ArrayList<Prescription>();

	static AbstractCollection<Labwork> LabworkList = 
		new ArrayList<Labwork>();
	
	/**
	 * Adds a new prescription.
	 * @param prescription
	 */
	public static void addPrescription(Prescription prescription){
		if(!PrescriptionList.contains(prescription)){
			PrescriptionList.add(prescription);
		}
	}
	
	/**
	 * Removes a prescription.
	 * @param prescriptionName
	 * @return the String of the prescription that was successfully removed.
	 */
	public static String removePrescription(String prescriptionName){
		for(Prescription p:PrescriptionList){
			if(p.getName().equals(prescriptionName)){
				PrescriptionList.remove(p);
				return prescriptionName;
			}
			
		}
		return null;
	}
	
	/**
	 * Finds a prescription.
	 * @param prescriptionName  Finds the prescription found.
	 * @return the string if the prescription is found.  Null otherwise.
	 */
	public static String findPrescription(String prescriptionName){
		for(Prescription p:PrescriptionList){
			if(p.getName().equals(prescriptionName)){
				return prescriptionName;
			}
			
		}
		return null;
	}
	
	public static void addLabwork(Labwork lab){
		if(!LabworkList.contains(lab)){
			LabworkList.add(lab);
		}
	}
	
	public static String removeLabwork(String Labname){
		for(Labwork la:LabworkList){
			if(la.getName().equals(Labname)){
				LabworkList.remove(la);
				return Labname;
			}
			
		}
		return null;
	}
	
	public static String findLabwork(String Labname){
		for(Labwork la:LabworkList){
			if(la.getName().equals(Labname)){
				return Labname;
			}
			
		}
		return null;
	}
}
